const { BaseAction , RequestParser , RequestAuth } = require("breeze-web") 
const IndexAction = new BaseAction("test")
const AuthConfig = RequestAuth.AuthConfig
const toAuth = AuthConfig.to 
const Group = "Test"
const ParamOption = RequestParser.ParamOption

IndexAction.get({
    path : "/ok"
} , async ctx => {
    ctx.body = "run ok."
})

IndexAction.get({
    path : "/login" 
} , async ctx => {
    ctx.session = {}
    ctx.session.new = {
        from : "cookie" ,
        group : Group , 
        data : {
            abc : "123"
        }
    }
})

IndexAction.get({
    path : "/index" , 
    params : [
        ParamOption.Pag() ,
        ParamOption.String("key" , "手机号/身份证" , 11 , 20 )
    ] ,
    auth : toAuth( Group , AuthConfig.cookie() , "测试")
} , async ctx => {
    const { pag , ps } = ctx.request 
    console.log( pag )
    console.log( ps )
    ctx.body = "test"
})

module.exports = IndexAction